﻿using SD.Infrastructure.EntityBase;
using System;
using System.Text;

namespace SlamDunk.MES.Domain.Entities.ConfigurationContext
{
    /// <summary>
    /// 工作通知
    /// </summary>
    public class Notification : AggregateRootEntity
    {
        #region # 构造器

        #region 00.无参构造器
        /// <summary>
        /// 无参构造器
        /// </summary>
        protected Notification() { }
        #endregion

        #region 01.创建工作通知构造器
        /// <summary>
        /// 创建工作通知构造器
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="content">内容</param>
        /// <param name="issuedDate">下发日期</param>
        /// <param name="facilityId">工厂模型Id</param>
        /// <param name="priority">优先级</param>
        /// <param name="description">描述</param>
        public Notification(string title, string content, DateTime issuedDate, Guid? facilityId, int priority, string description)
            : this()
        {
            base.Number = title;
            base.Name = content;
            this.IssuedDate = issuedDate.Date;
            this.FacilityId = facilityId;
            this.Priority = priority;
            this.Description = description;

            //初始化关键字
            this.InitKeywords();
        }
        #endregion

        #endregion

        #region # 属性

        #region 下发日期 —— DateTime IssuedDate
        /// <summary>
        /// 下发日期
        /// </summary>
        public DateTime IssuedDate { get; private set; }
        #endregion

        #region 工厂模型Id —— Guid? FacilityId 
        /// <summary>
        /// 工厂模型Id
        /// </summary>
        public Guid? FacilityId { get; private set; }
        #endregion

        #region 优先级 —— int Priority
        /// <summary>
        /// 优先级
        /// </summary>
        /// <remarks>数值越大，优先级越高</remarks>
        public int Priority { get; private set; }
        #endregion

        #region 描述 —— string Description
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; private set; }
        #endregion

        #endregion

        #region # 方法

        #region 初始化关键字 —— void InitKeywords()
        /// <summary>
        /// 初始化关键字
        /// </summary>
        private void InitKeywords()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(base.Number);
            builder.Append(base.Name);
            builder.Append(this.Description);

            base.SetKeywords(builder.ToString());
        }
        #endregion

        #endregion
    }
}
